<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%@ include file="../../header_inc.jsp"%>
<script type="text/javascript">
	//所有的子窗体都需要有一个save函数，当点击弹出窗体的保存按钮时所进行的操作

	function btnSave_click() {
		var fun_ret;
		var file = $('#uploadFile')[0];
		var imagSize =  document.getElementById("uploadFile").files[0];
		if(imagSize != null && imagSize != "" && !isNull( imagSize )){
			
			imagSize = imagSize.size;
		}
		name = file.value;
		var pic = '.+(.JPEG|.jpeg|.JPG|.jpg|.GIF|.gif|.BMP|.bmp|.PNG|.png)$';
		var end = name.substr(name.lastIndexOf("."));
		if (name != "" && name != null && end !=".jpg" && end !=".JPEG" && end !=".jpeg" &&end !=".JPG" && end !=".PNG" && end !=".png" ) {
			$.messager.alert("提示", " 您选择的不是图片文件，请重新选择！");
			return false;
		}else{
			if(imagSize > 404800){
					$.messager.alert("错误提示", "图片需要限制在200kb以内！");
			        return false;
			}
		}
		var formData = new FormData($('#formModule')[0]);
		var url = '${saveUrl}';
			$.ajax({
				type : "POST",
				url : url,
				data : formData,
				async: false,
				cache : false,
				contentType : false,
				processData : false,
				dataType:'json',//请求的数据类型
				success : function(data) {
					if (data.success != 0) {
						//top.Ext.Msg.alert("提示",data.msg);
						Ext.Msg.alert("提示", data.msg);
					} else {
						fun_ret = true;
					}
				}
			});
	return fun_ret;
	}
	 $(document).ready(function(){
				
				 $.ajax({
					    url:"${ctx }/manage/commodityCategory/getCategory",
					    type:"post",
					    dataType:"json",
					    success:function(data){
					        $('#categoryId').combobox({ 
					            data:data.rows,
					            valueField:'categoryId', 
					            textField:'name',
					            onLoadSuccess: function (data) { //加载完成后,设置选中第一项
					                var val = $(this).combobox("getData");
					              	var tid="0" + "${model.commodityCategory.categoryId}";
		    						var typeId = parseInt(tid);
		    						for (var item in val[0]) {
									if(typeId > 0)
		    							{
											$(this).combobox("select", typeId);
		    							}
									else if(item == "categoryId")
										{
										 	$(this).combobox("select", val[0][item]);
										}
					              
		    						}
					            }
					        });        
					    }
					});
					
			  });

</script>
</head>
<body>
	<div style="padding: 10px" align="center">
	
		<form id="formModule" method="post">
			<table border="0">
			<tr height="0">
					<td><c:if test="${!empty model.orderCount }"><input type="hidden" value="${model.orderCount}" name="orderCount"></input></c:if></td>
				</tr>
		   <tr height="0">
					<td><c:if test="${!empty model.viewCount }"><input type="hidden" value="${model.viewCount }" name="viewCount"></input></c:if></td>
				</tr>
			
			<tr height="0">
					<td><c:if test="${!empty model.createTime}"><input type="hidden" value="${model.createTime }" name="createTime"></input></c:if></td>
				</tr>
			
				<tr height="0">
					<td><c:if test="${!empty model.commodityId }"><input type="hidden" value="${model.commodityId}" name="commodityId"></input></c:if></td>
				</tr>
				<tr height="30">
					<td>商品名称：</td>
					<td><input id="names" maxlength="10"
						class="easyui-validatebox textbox" type="text"
						name="names" data-options="required:true"
						style="width: 180px;height: 25px" value="${model.names }"></input></td>
				</tr>

				
				 <tr>
                    <td height="30">商品图片：</td>
                    <td><input type="file" class="easyui-linkbutton"
						data-options="toggle:true,group:'g2',plain:true"
						accept="image/*" id="uploadFile"
						name="uploadFile" style="width: 200px;" /></td>
                </tr>	
                <c:if test="${!empty model.photo }">
                <tr height="30">
				
					<td>图片：</td>
					<td> <img alt=""  width="100" height="100" src="${model.photo }"></td>
				</tr>
                </c:if>
                
                <tr height="50">
					<td>描述：</td>
					<td><textarea id="summary" maxlength="200" 
						class="easyui-validatebox textbox" 
						name="summary" data-options="required:true"
						style="width: 180px" cols="5" >${model.summary }</textarea></td>
				</tr>
                
                
				
			<tr height="30">
					<td>原价：</td>
					<td><input id="nativePrice" maxlength="10" 
						class="easyui-validatebox textbox" type="text" onkeyup="value=value.replace(/[^1234567890.]+/g,'')"
						name="nativePrice" data-options="required:true"
						style="width: 180px;height: 25px" value="${model.nativePrice }"></input></td>
				</tr>
				
			<tr height="30">
					<td>价格：</td>
					<td><input id="price" maxlength="10" 
						class="easyui-validatebox textbox" type="text" onkeyup="value=value.replace(/[^1234567890.]+/g,'')"
						name="price" data-options="required:true"
						style="width: 180px;height: 25px" value="${model.price }"></input></td>
				</tr>
				<tr height="30">
					<td>库存：</td>
					<td><input id="number" maxlength="10" 
						class="easyui-validatebox textbox" type="text"  onkeyup="value=value.replace(/[^1234567890]+/g,'')"
						name="number" data-options="required:true"
						style="width: 180px;height: 25px" value="${model.number }"></input></td>
				</tr>
			<!-- 	<tr height="30">
					<td>所属单位：</td>
                    <td><select id="depId" name="sysDepartment.depId" class="easyui-combotree" style="width:180px;height:25px" data-options="required:true,editable:false"></select>
                    </td>
					
				</tr> -->
			 <tr height="30">
					<td>商品类别：</td>
					
				
                    <td><select id="categoryId" name="commodityCategory.categoryId" class="easyui-combobox" style="width:180px;height:25px" data-options="required:true,editable:false,panelHeight:'auto'"></select>
                    </td>
					 
				</tr>
				<tr height="30">
				
					<td>状态：</td>
					<td><select id="status" name="status">
							<option value="9" <c:if test="${model.status==9 }">selected</c:if>>正常</option>
							<option value="0" <c:if test="${model.status==0 }">selected</c:if>>禁用</option>
					</select></td>
				</tr>
				
        
         
                
			</table>
		</form>
	</div>
</body>
</html>
